<?php

namespace app\proxyapi\controller;

use app\data\model\LiveAppproxy;
use app\data\model\LiveIntegralRecord;
use app\data\model\LiveProxyList;

class ManageIntegral extends BaseProxyController
{
    //积分记录
    public function getInteList(){
        $userId = $this->checkTokenReturnUserId();
        $post = $this->request->post();
        if(!isset($post['appName'], $post['packageName'], $post['versionName'], $post['versionCode'])) $this->error('缺少参数！');
        $app = LiveAppproxy::mk()->where(['app_name'=>$post['appName'],'app_package'=>$post['packageName'],'deleted'=>0])->find();
        if(empty($app)) $this->error('不存在当前应用！');

        $proxy = LiveProxyList::mk()->where(['id'=>$userId])->find();
        //积分类型 1收入 2支出、积分数量、积分余额、创建时间、备注
        $records = LiveIntegralRecord::mk()
            ->field('integral_type,integral_num,integral_balance,create_time,remarks')
            ->where(['uuid'=>$userId])
            ->order('create_time desc')->select()->toArray();
        $this->success('sussess',$records);
    }
    //积分套餐


}